<?php
/**
 * CreateTime: 2023/11/24 10:43
 * User:LinQ
 */

namespace App\Models\CompanyDepartment;

use App\Models\BasicModel;
use App\Models\Users\UsersModel;

class CompanyModel extends BasicModel
{
    protected $table = 's_company';

    protected $primaryKey = 'company_id';

    protected $fillable = [
        'company_id',
        'company_name',
        'company_code',
        'company_union_id',
        'created_at',
        'updated_at',
    ];

    protected $casts = [
        'company_id' => 'integer',
        'company_name' => 'string',
        'company_code' => 'string',
        'company_union_id' => 'string',
        'created_at' => 'string',
        'updated_at' => 'string ',
    ];

    protected $guarded = [
        'company_id',
        'company_union_id',
        'created_at',
        'updated_at',
    ];

    protected $hidden = [
        'created_at',
        'updated_at',
    ];


    public function users(){
        return $this->hasMany(UsersModel::class,'com_id','company_id');
    }

    public function departments(){
        return $this->hasMany(DepartmentModel::class,'com_id','company_id');
    }

}